/** 
 * @description 导出组件为其他的项目使用
 * !! 此文件作为导出组件的入口，不在项目中引用
*/

/** 此文件作为导出组件的入口，不在项目中引用 */
import '@src/assets/scss/reboot.scss'
import '@src/assets/scss/transition.scss'
import '@src/assets/scss/base.scss'
import '@src/exports/element.scss'
/* 兼容垫片 */
import '@src/common/polyfill'

import Vue from 'vue'

/* components */
import BaseOpenData from '@src/component/common/BaseOpenData'
import BaseModal from '@src/component/common/BaseModal'
/* components connector 连接器组件 */
import ConnectorCreateDialog from '@src/modules/connector/components/create-connector-dialog'
import ConnectorEditDialog from '@src/modules/connector/components/edit-connector-dialog'
import ConnectorCard from '@src/modules/connector/components/connector-card'
import { BuildComponents, ViewComponents, SettingComponents } from '@src/component/form/components'
import AdvancedSearchFieldComponents from '@src/component/AdvancedSearch/FieldComponents'
/* enum */
import ComponentNameEnum from '@model/enum/ComponentNameEnum'
/* vue */
import filter from '@src/filter'
import directive from '@src/directive'
/* util */
import { isNotUndefined } from '@src/util/type'
import { addComponentNamePrefix } from '@src/util/component'

const formComponents = {
  ...BuildComponents,
  ...ViewComponents,
  ...SettingComponents,
}

let components = {
  [BaseModal.name]: BaseModal,
  [BaseOpenData.name]: BaseOpenData,
  [ConnectorCreateDialog.name]: ConnectorCreateDialog,
  [ConnectorEditDialog.name]: ConnectorEditDialog,
  [ConnectorCard.name]: ConnectorCard,
}

function install(Vue) {
  
  Vue.prototype.$ELEMENT = { size: 'small' }
  
  Vue.use(directive)
  Vue.use(filter)
  
  for (const componentName in components) {
    Vue.component(componentName, components[componentName])
  }
  
  Object.keys(formComponents).forEach(name => {
    
    let component = formComponents[name]
    const componentName = addComponentNamePrefix(name)
    
    component.name = componentName
    components[componentName] = component
    
    Vue.component(componentName, component)
    
  })
  
  Object.keys(AdvancedSearchFieldComponents).forEach(name => {
    
    let component = AdvancedSearchFieldComponents[name]
    const originComponentName = component.name
    const componentName = addComponentNamePrefix(originComponentName)
    
    component.name = componentName
    
    components[componentName] = component
    
    Vue.component(componentName, component)
    
  })
  
}

window.publink_shb_pc_fe_components = components
window.publink_shb_pc_fe_components_install = install

if (isNotUndefined(window.Vue)) {
  install(window.Vue)
}

export default components

